package com.knowledgegraph.web.controller.zhongyao;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.knowledgegraph.common.annotation.Log;
import com.knowledgegraph.common.core.controller.BaseController;
import com.knowledgegraph.common.core.domain.AjaxResult;
import com.knowledgegraph.common.enums.BusinessType;
import com.knowledgegraph.zhongyao.domain.Bing;
import com.knowledgegraph.zhongyao.service.IBingService;
import com.knowledgegraph.common.utils.poi.ExcelUtil;
import com.knowledgegraph.common.core.page.TableDataInfo;

/**
 * 病例类型维护Controller
 * 
 * @author ruoyi
 * @date 2023-07-25
 */
@RestController
@RequestMapping("/zhongyao/bing")
public class BingController extends BaseController
{
    @Autowired
    private IBingService bingService;

    /**
     * 查询病例类型维护列表
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:bing:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bing bing)
    {
        startPage();
        List<Bing> list = bingService.selectBingList(bing);
        return getDataTable(list);
    }

    /**
     * 导出病例类型维护列表
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:bing:export')")
    @Log(title = "病例类型维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bing bing)
    {
        List<Bing> list = bingService.selectBingList(bing);
        ExcelUtil<Bing> util = new ExcelUtil<Bing>(Bing.class);
        util.exportExcel(response, list, "病例类型维护数据");
    }

    /**
     * 获取病例类型维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:bing:query')")
    @GetMapping(value = "/{bingId}")
    public AjaxResult getInfo(@PathVariable("bingId") Long bingId)
    {
        return AjaxResult.success(bingService.selectBingByBingId(bingId));
    }

    /**
     * 新增病例类型维护
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:bing:add')")
    @Log(title = "病例类型维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bing bing)
    {
        return toAjax(bingService.insertBing(bing));
    }

    /**
     * 修改病例类型维护
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:bing:edit')")
    @Log(title = "病例类型维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bing bing)
    {
        return toAjax(bingService.updateBing(bing));
    }

    /**
     * 删除病例类型维护
     */
    @PreAuthorize("@ss.hasPermi('zhongyao:bing:remove')")
    @Log(title = "病例类型维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bingIds}")
    public AjaxResult remove(@PathVariable Long[] bingIds)
    {
        return toAjax(bingService.deleteBingByBingIds(bingIds));
    }
}
